package helper

import (
	"github.com/eeppee_admin/clouddisk/service/define"
	"github.com/dgrijalva/jwt-go"
	"time"

)



func GenerateToken(id int, identity, name string, second int) (string, error) {
	// id
	// identity
	// name
	uc := define.UserClaim {
		Id: id,
		Identity: identity,
		Name: name,
		StandardClaims: jwt.StandardClaims{
			ExpiresAt: time.Now().Add(time.Second * time.Duration(second)).Unix(),
		},
	}

	token := jwt.NewWithClaims(jwt.SigningMethodHS256, uc)
	tokenString, err := token.SignedString([]byte(c.Jwt.SignerKey))
	if err != nil {
		return "", err
	}

	return tokenString, nil
}

